/*
@author: stanfor
@date: 2022/8/22 18:41
@Version: 1.0
@last modify time : 2022/8/22 18:41
*/

import React, { FC, ReactElement } from 'react';
import { InputNumber, Col, Form, InputNumberProps } from 'antd';
import { getRulesConfig, commonInterface } from '@C/base/SFields/constant';
import './index.less';

interface IProps extends commonInterface{
  // 是否填充剩余部分
  isForcedFill: boolean;
}

const Index: FC<Partial<IProps> & Partial<Omit<InputNumberProps, 'type'>>> = (props): ReactElement => {
  const { name, label = '标签', span = 8, required = false, ruleIcon, isForcedFill, formItemConfig, ...numberProps } = props;

  return (
    <Col span={span}>
      <div className="base-component-super-fields-common">
        <Form.Item
          label={label}
          name={name}
          rules={getRulesConfig(required, label, ruleIcon)}
          {...formItemConfig}
        >
          <InputNumber {...numberProps} style={{ width: isForcedFill ? '100%' : '' }} />
        </Form.Item>
      </div>
    </Col>
  );
};

export default Index;
